﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace ARR.Entities
{
    [DataContract]
    public class ImporterResult
    {
        [DataMember]
        public int Id { get; set; }

        [DataMember]
        public ResultCategory Category { get; set; }

        [DataMember]
        public string Location { get; set; }

        [DataMember]
        public string Description { get; set; }

        [DataMember]
        public ErrorType ErrorType { get; set; }

        [DataMember]
        public Workaround? Workaround { get; set; }

        [DataMember]
        public int ItemId { get; set; }

        [DataMember]
        public string ItemText { get; set; }
        
        [DataMember]
        public string CreateErrorMessageSingleLineFormated
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(Location))
                {
                    return string.Format("Error #{0}:  [Type]='{1}'    [Category]='{2}'    [Description]='{3}'     [Location]='{4}'", Id, ErrorType.ToString(), Category.ToString(), Description, Location);
                }
                else
                {
                    return string.Format("Error #{0}:  [Type]='{1}'    [Category]='{2}'    [Description]='{3}'", Id, ErrorType.ToString(), Category.ToString(), Description);
                }
            }
            set { }
        }


        [DataMember]
        public string Param1 { get; set; }
        
        [DataMember]
        public string Param2 { get; set; }
        
        [DataMember]
        public string Param3 { get; set; }

        [DataMember]
        public string Param4 { get; set; }

        [DataMember]
        public string Param5 { get; set; }


        [DataMember]
        public bool IsSelected { get; set; }
    }
    
    public enum ResultCategory
    {
        PreRequisites,
        TemporalTable,
        Validation,
        Updating
    }

    public enum ErrorType
    {
        Information = 1,
        Warning = 2,
        Error = 3
    }


    public enum Workaround
    {
        EditArticleInGrid,
        MatchCategory,
        UnifyRepeatedNames,
        CategoryMargin,
        MissingSegmentation,
        MissingSales,
        UnitsIsZero,
        SalesOrMarginIsZero,
        NegativeUnits,
        MissingArticleId,
        MissingCategory,
        MissingStoreId,
        MissingCountry,
        Duplicated,
        StoresAverage,
        ImportSummary,
        SpacesTotals,
        WidthIsZero,
        NullCosts,
        Segmentation
    }
}
